#!/usr/bin/node

"use strict";

const mkdir = require("mkdir-promise");
const touch = require("touch");
const path = require("path");
const chmod = require("chmod");

// create logs
mkdir(path.join(__dirname, "..", "logs"))
  .then(function() {
    touch(path.join(__dirname, "..", "logs", "dev.info.log"));
    touch(path.join(__dirname, "..", "logs", "dev.error.log"));
    touch(path.join(__dirname, "..", "logs", "prod.info.log"));
    touch(path.join(__dirname, "..", "logs", "prod.error.log"));
  })
  .catch(err => console.log(err));

// create localstorage
mkdir(path.join(__dirname, "..", "database"))
  .then(function() {
    touch(path.join(__dirname, "..", "database", "localstorage.dev.sqlite3"));
    touch(path.join(__dirname, "..", "database", "localstorage.prod.sqlite3"));
    chmod(path.join(__dirname, "..", "database", "localstorage.dev.sqlite3"), 777);
    chmod(path.join(__dirname, "..", "database", "localstorage.prod.sqlite3"), 777);
  })
  .catch(err => console.log(err));
